package com.lujianfei.filesend.base

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
abstract class BaseFragment<DB: ViewDataBinding?>: Fragment() {

    protected var binding: DB?= null

    private var needAnim:Boolean = true

    abstract fun resourceId():Int
    abstract fun initView()
    abstract fun initData()
    abstract fun initEvent()

    inline fun <reified VM: ViewModel> buildViewModel() = ViewModelProvider(this)[VM::class.java]

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DataBindingUtil.inflate(inflater, resourceId(), container, false)
        return binding?.root
    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
        initEvent()
        initData()
    }
}